$(function () {
    layui.use(['upload', 'element', 'jquery', 'layer', 'form'], function () {
        var $ = layui.jquery;
        let form = layui.form;


        let id = sessionStorage.getItem("newsId");
        findById(id);

        function findById(id) {
            console.log(id)
            $.ajax({
                url: '/back/news/findById',
                data: {id: id},
                type: 'get',
                dataType: "json",
                success: function (res) {
                    console.log(res.data)
                    setData(res.data);
                }
            })
        }

        function setData(data) {
            console.log(data)
            $("#pic").attr("src", data.img)
            // 重新渲染表单
            form.render();
        }
    })
})